import axios from 'axios';
 
const apiClient = axios.create({
  baseURL: 'http://localhost:3000/api', // 替换为你的后端API地址
  withCredentials: false, // This is the default
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json'
  }
});
 
export default {
  getPosts() {
    return apiClient.get('/posts');
  },
  getPost(id) {
    return apiClient.get('/posts/' + id);
  },
  addPost(post) {
    return apiClient.post('/posts', post);
  },
  updatePost(post) {
    return apiClient.put('/posts/' + post.id, post);
  },
  deletePost(id) {
    return apiClient.delete('/posts/' + id);
  }
};
